window.onload = function () {
  var regtel = /^(13[0-9]|14[5-9]|15[0-3,5-9]|16[2,5,6,7]|17[0-8]|18[0-9]|19[0-3,5-9])\\d{8}$/; //手机号正则表达式
  var regqq = /^[1-9]\d{4,}$/; // qq号
  var regnc = /^[\u4e00-\u9fa5]{2,8}$/; // 汉字
  var resmsg = /^\d{6}$/; // 短信
  var regpwd = /^[a-zA-Z-0-9_-]{6,16}$/; // 密码
  var tel = document.querySelector("#tel");
  var qq = document.querySelector("#qq");
  var nc = document.querySelector("#nc");
  var msg = document.querySelector("#msg");
  var pwd = document.querySelector("#pwd");
  var surepwd = document.querySelector("#surepwd");
  regexp(tel, regtel); // tel
  regexp(qq, regqq); // qq
  regexp(nc, regnc); // 昵称
  regexp(msg, resmsg); // 短信
  regexp(pwd, regpwd); // 密码

  function regexp(ele, reg) {
    ele.onblur = function () {
      if (reg.test(this.value)) {
        this.nextElementSibling.className = "success";
        this.nextElementSibling.innerHTML = `<i class='success_icon'></i>恭喜您输入正确`;
      } else {
        this.nextElementSibling.className = "error";
        this.nextElementSibling.innerHTML = `<i class='error_icon'></i>格式不对`;
      }
    };
  }
  surepwd.onblur = function () {
    if (this.value == pwd.value) {
      this.nextElementSibling.className = "success";
      this.nextElementSibling.innerHTML = `<i class='success_icon'></i>恭喜您输入正确`;
    } else {
      this.nextElementSibling.className = "error";
      this.nextElementSibling.innerHTML = `<i class='error_icon'></i>密码不一致`;
    }
  };
};
